package com.personal.dao;

import com.personal.domain.Supplier;
import com.personal.util.partDisplay.SupplierPart;
import org.apache.ibatis.annotations.*;

import java.util.List;



@Mapper
public interface SupplierDao {


    @Select("select * from supplier")
    List<Supplier> selectAll();


    @Select("select id,supplierName,supplierCode,supplierLink,businessScope,contact,contactPhone,forbidden,parkSharing,remark from supplier")
    List<SupplierPart> selectPartAll();

    @Select("select id,supplierName,supplierCode,supplierLink,businessScope,contact,contactPhone,forbidden,parkSharing,remark from supplier" +
            " where supplierName like CONCAT('%',#{name},'%') and supplierCode like CONCAT('%',#{code},'%')")
    List<SupplierPart> selectPartByKey(String name,String code);


    @Insert(" insert into supplier (id, attributionRange, supplierCode, supplierName, contact, contactPhone, supplierLink," +
            "                              supplierAddress, businessScope, forbidden, parkSharing, remark) VALUE" +
            "                            (null, #{attributionRange},#{supplierCode},#{supplierName},#{contact},#{contactPhone},#{supplierLink}," +
            "                            #{supplierAddress},#{businessScope},#{forbidden},#{parkSharing},#{remark})")
    int add(Supplier supplier);


    @Select("select * from supplier where id=#{id}")
    Supplier getUpdateData(int id);
    @Update("update supplier set attributionRange=#{attributionRange},supplierCode=#{supplierCode},supplierName=#{supplierName},contact=#{contact}," +
            "                            contactPhone=#{contactPhone},supplierLink=#{supplierLink},supplierAddress=#{supplierAddress}," +
            "                            businessScope=#{businessScope},forbidden=#{forbidden},parkSharing=#{parkSharing},remark=#{remark}" +
            "                            where id=#{id}")
    int update(Supplier supplier);


    @Delete("delete from supplier where id=#{id}")
    int delete(int id);

}
